<%@page import="com.metagurukul.metagranth.vo.User"%>
<%@page import="com.metagurukul.metagranth.vo.Tag"%>
<%@page import="com.metagurukul.metagranth.vo.MetaData"%>
<%@include file="header.jsp"%>
<%
if(session.getAttribute("userType")==null){
	%><script type="text/javascript">window.location='index.jsp'</script><%
}else {
	if(Integer.parseInt(session.getAttribute("userType").toString())!=1){
	%><script type="text/javascript">window.location='access-denied.jsp'</script><%
	}
}
%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"
	import="java.util.ArrayList,com.metagurukul.metagranth.vo.Question"%>

<%
	if (request.getAttribute("metaDataList") == null) {
		request.getRequestDispatcher("adminquestion.do").forward(
				request, response);
	} else {
		ArrayList<MetaData> metaDataList = (ArrayList<MetaData>) request
				.getAttribute("metaDataList");
		
%>

<table width="900px" border="0" align="center">
	
	<tr>
		<td colspan="3">&nbsp;</td>
	</tr>
	<%if(metaDataList.size()!=0){ %>
	<tr>
		<td colspan="3" class="question-header">Question Still Open..!!</td>
	</tr>

	<%} else { %>
	<tr>
		<td colspan="3" class="question-header">No Question To Approve!!</td>
	</tr>
	<%} %>
		<tr>
		<td colspan="3" class="green">Which has atleast One Answer...!!</td>
	</tr>
	<tr>
		<td colspan="3" height="50px" valign="top"><hr />
		</td>
	</tr>
	
	<%
		for (MetaData metaData : metaDataList) {
				Question question = metaData.getQuestion();
				ArrayList<Tag> tagList = metaData.getTagList();
				User user = metaData.getUser();
				String dateTime = question.getDateOfPost().toString();

				String date = dateTime.substring(0, 10);
				String time = dateTime.substring(10);
	%>
	<tr>
		<td class="question-hyperlink"><a
			href="admin-approve-answer.do?questionId=<%=question.getQuesId()%>">
				<%
					out.print(question.getTitle().substring(0, 1).toUpperCase());

							if (question.getTitle().length() > 1) {
								if (question.getTitle().length() > 50) {
									out.println(question.getTitle().substring(1, 50)
											+ "...");
								} else {
									out.println(question.getTitle().substring(1,
											question.getTitle().length()));
								}
							}
				%>
		</a></td>
		<td align="right" valign="bottom" class="excerpt" width="200px">Posted
			By : <%=user.getName()%></td>
	</tr>
	<tr>
		<td>
			<%
				for (Tag tag : tagList) {
			%> <a href="searchQuestionByTag.do?tagFilterId=<%=tag.getTagid()%>"
			class="post-tag" title="" rel="tag"><%=tag.getTagName()%></a> <%
 	}
 %>
		</td>
		<td align="right" valign="bottom" class="excerpt">Time :<%=time.substring(0, time.length() - 2)%>
			&nbsp;Date : <%=date%></td>
	</tr>
	<tr>
		<td colspan="2" style="border-top: 1px dotted #000000;" height="8px"
			valign="middle">&nbsp;</td>
	</tr>
	<%
		}
	%>

</table>
<%
	request.removeAttribute("metaDataList");
	}
%>

<%@include file="footer.jsp"%>